/**
 * 
 */
package net.teamclerks.rpgf.character.statsheet;

import java.util.LinkedList;

import net.teamclerks.rpgf.character.Character;
import net.teamclerks.rpgf.character.stats.StatSheet;
import net.teamclerks.rpgf.script.director.Director;

/**
 * @author msmith
 *
 */
public class CharacterEffectStatSheet extends StatSheet
{
  /// DATA POINTS ///
  protected Character owner;
  protected LinkedList<StatusEffectStatSheet> effects;
  
  /// PUBLIC CONSTRUCTOR ///
  public CharacterEffectStatSheet(Director director, Character owner)
  {
    super(director);
    this.owner = owner;
    this.owner.setCharacterEffectStatSheet(this);
    effects = new LinkedList<StatusEffectStatSheet>();
  }
  
  /// PROTECTED METHODS ///
  /**
   * AddStatus is a protected method definition that is always called
   * by the public-accessible method <code>applyStatus</code> meant to
   * be overridden for implementation-specific rules.
   */
  protected void addStatus(StatusEffectStatSheet effect){}
  /**
   * DropStatus is a protected method definition that is always called
   * by the public-accessible method <code>removeStatus</code> meant to
   * be overridden for implementation-specific rules.
   */
  protected void dropStatus(StatusEffectStatSheet effect){}
  
  /// PUBLIC FINAL METHODS ///
  /**
   * Adds the stats of the given {@link StatusEffectStatSheet} to this {@link CharacterEffectStatSheet}
   * and adds the effect to the list of effects for this {@link CharacterEffectStatSheet}.<br/><br/>
   * Calls <code>addStatus</code> which does nothing by default but may do
   * something per implementation.
   * @param effect
   */
  public final void applyStatus(StatusEffectStatSheet effect)
  {
    if(effects.add(effect))
    {
      this.addStatus(effect);
      this.applyStats(effect);
    }
  }
  /**
   * Removes the stats of the given {@link StatusEffectStatSheet} and removes
   * it from the list of effects for this {@link CharacterEffectStatSheet}.
   * Calls <code>dropStatus</code> which does nothing by default but may do
   * something per implementation.
   * @param effect
   */
  public final void removeStatus(StatusEffectStatSheet effect)
  {
    if(effects.remove(effect))
    {
      this.dropStatus(effect);
      this.removeStats(effect);
    }
  }
  /**
   * Gets the list of {@link StatusEffect} on this {@link CharacterEffectStatSheet}.
   */
  public final LinkedList<StatusEffectStatSheet> getStatusEffects()
  {
    return effects;
  }
  /**
   * Sets the list of {@link StatusEffect} on this {@link CharacterEffectStatSheet}.
   * @param effects
   */
  public final void setStatusEffects(LinkedList<StatusEffectStatSheet> effects)
  {
    this.effects = effects;
  }
  /**
   * Gets the Character who owns this CharacterEffectStatSheet.
   * @return owner
   */
  public final Character getOwner()
  {
    return this.owner;
  }
}
